package server.servlet;

import servlet.HttpProtocolUtil;
import servlet.HttpServlet;
import servlet.Request;
import servlet.Response;

import java.io.IOException;

/**
 * Created by louisyuu on 2020/4/3 上午9:42
 */
public class MinicatServlet extends HttpServlet {
    @Override
    protected void doGet(Request request, Response response) throws Exception {
        doPost(request, response);
    }

    @Override
    protected void doPost(Request request, Response response) throws Exception {
        System.out.println("Request to demo servlet");
        System.out.println("Request method type " + request.getMethod());
        System.out.println("Request url " + request.getUrl());


        String content = "<h1>Welcome to mini cat ...</h1>";
        try {
            response.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
